package com.gdut.simple.view.fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.gdut.simple.R;
import com.gdut.simple.basic.BasicApplication;
import com.gdut.simple.common.LogUtils;
import com.gdut.simple.common.ToastUtils;
import com.gdut.simple.data.entity.Note;
import com.gdut.simple.data.entity.User;
import com.gdut.simple.view.activity.explore.HotPickActivity;
import com.gdut.simple.view.activity.explore.NewsActivity;
import com.gdut.simple.view.activity.explore.NoteActivity;
import com.gdut.simple.view.activity.explore.OtherUserInfoActivity;
import com.gdut.simple.view.activity.explore.ResourceActivity;
import com.gdut.simple.view.activity.explore.SquareActivity;
import com.gdut.simple.view.basic.AbsBasicFragment;
import com.google.zxing.activity.CaptureActivity;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;

public class ExploreFragment extends AbsBasicFragment {

    @BindView(R.id.id_toolbar)
    Toolbar mToolbar;

    @OnClick(R.id.id_square_button)
    public void gotoSquare() {
        startActivity(new Intent(getActivity(), SquareActivity.class));
    }

    @OnClick(R.id.id_wiki_button)
    public void gotoWiki() {
        startActivity(new Intent(getActivity(), NoteActivity.class));
    }

    @OnClick(R.id.ic_scan_button)
    public void gotoScan() {
        startActivityForResult(new Intent(getActivity(), CaptureActivity.class), Activity.RESULT_FIRST_USER);
    }

    @OnClick(R.id.id_res_download_button)
    public void gotoResource() {
        startActivity(new Intent(getActivity(), ResourceActivity.class));
    }

    @OnClick(R.id.id_hot_pcik_button)
    public void gotoHotPick() {
        startActivity(new Intent(getActivity(), HotPickActivity.class));
    }

    @OnClick(R.id.id_news_button)
    public void gotoNews() {
        startActivity(new Intent(getActivity(), NewsActivity.class));
    }

    public static ExploreFragment newInstance() {
        return new ExploreFragment();
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_explore, container, false);
        ButterKnife.bind(this, view);
        initToolbar();
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }

    private void initToolbar() {
        mToolbar.setTitle(R.string.nav_explore);
    }

    @Override
    public void fetchData() {

    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == Activity.RESULT_FIRST_USER) {
            if (resultCode == Activity.RESULT_OK) {
                Bundle bundle = data.getExtras();
                final String result = bundle.getString("result");
                OtherUserInfoActivity.startActivity(getActivity(), result);
            }
        }
    }
}
